package com.csi.controller;

import com.csi.service.IndexService;
import com.csi.utils.JsonResult;
import com.csi.utils.ReturnResults;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Tag(name = "index",description="首页旅游套餐API")
@RestController
@RequestMapping("/index/travel")
public class IndexController {

    @Autowired
    private IndexService indexService;

    /**
     * 返回评分前六的旅游套餐
     * @return
     */
    @Operation(summary = "查找评分前六的旅游套餐",description = "查找评分前六的旅游套餐")
    @GetMapping("/list")
    public Object list() {
        List<Map<String,Object>> list = indexService.list();

        if (list != null && list.size() > 0) {
            return new JsonResult(list);
        }
        return new JsonResult(ReturnResults.ACCESS_FAILED,"失败了");
    }
}
